package com.junjiao.util.web;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ApplicationContextUtil {
	private static ApplicationContext ctx = null;

	public ApplicationContextUtil() {
	}

	public static ApplicationContext getCtx() throws Exception {

        String[] locations = {"bean1.xml", "bean2.xml", "bean3.xml"};

                ApplicationContext ctx = new ClassPathXmlApplicationContext(locations);
		
		if (ctx == null)
			throw new Exception("ApplicationContext is null, pls check it!");
		else
			return ctx;
	}

	public static void setCtx(ApplicationContext ctx) {
		ApplicationContextUtil.ctx = ctx;
	}

}
